﻿namespace RecruitmentAgency.Models.DataTypes
{
    /// <summary>
    /// The RecruitmentAgency.Models.Cv.DataTypes.PersonQualification contains the details of a qualification that belongs to the user whose ID number is specified with the PersonId property
    /// </summary>
    public class PersonQualification
    {
        /// <summary>
        /// Gets or sets the ID number of the qualification
        /// </summary>
        public int PersonQualificationId { get; set; }

        /// <summary>
        /// Gets or sets the ID number of the user that the qualification relates to
        /// </summary>
        public int PersonId { get; set; }

        /// <summary>
        /// Gets or sets the name of the qualification
        /// </summary>
        public string QualificationName { get; set; }

        /// <summary>
        /// Gets or sets the subject of the qualification
        /// </summary>
        public string Subject { get; set; }

        /// <summary>
        /// Gets or sets the type of the qualification
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// Gets a Boolean value that determines whether the qualification is vocational
        /// </summary>
        public bool Vocational { get; set; }

        /// <summary>
        /// Gets or sets the name of the institution that awarded the qualification
        /// </summary>
        public string AwardedBy { get; set; }

        /// <summary>
        /// Gets or sets the year the qualification was awarded
        /// </summary>
        public string Year { get; set; }

        /// <summary>
        /// Gets or sets the result of the qualification
        /// </summary>
        public string Result { get; set; }

        /// <summary>
        /// Gets or sets a Boolean value that determines whether the qualification has been verified
        /// </summary>
        public bool QualificationVerified { get; set; }

        /// <summary>
        /// Gets or sets the type of verification received for the qualification
        /// </summary>
        public string QualificationVerificationType { get; set; }

        /// <summary>
        /// Gets a Boolean value that determines whether the RecruitmentAgency.Models.Cv.DataTypes.PersonQualification is to be considered to be null
        /// </summary>
        public bool IsNull
        {
            get
            {
                return QualificationName == null && Subject == null && Type == null && AwardedBy == null && (Year == null || Year == "0") && Result == null;
            }
        }

        /// <summary>
        /// Returns a short summary of the qualification
        /// </summary>
        /// <returns>A short summary of the qualification</returns>
        public string ToShortString()
        {
            string word = Result.ToLower().StartsWith("a") || Result.ToLower().StartsWith("e") || Result.ToLower().StartsWith("i") || Result.ToLower().StartsWith("o") || Result.ToLower().StartsWith("u") ? "an" : "a";
            string word2 = Subject.ToLower().StartsWith("a") || Subject.ToLower().StartsWith("e") || Subject.ToLower().StartsWith("i") || Subject.ToLower().StartsWith("o") || Subject.ToLower().StartsWith("u") ? "an" : "a";
            return string.Format("Awarded {0} {1} in {2} {3} {4} in {5} by {6}.", word, Result, word2, Subject, Type, Year.ToString(), AwardedBy);
        }
    }
}